package com.icss.lesson5;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;

public class TestMain3 {
    public static void main(String[] args) {

        Map<String, String> map1 = new HashMap<>();


        map1.put("a2", "是是是");
        map1.put("a2", null);
        map1.put(null, "lkjdjflkas");
        map1.put("00600", "大连");
        map1.put("a1", "是是是");
        map1.put("a1", "dame");

        System.out.println(map1.size()); // 4
        System.out.println(map1.get("a2"));
        System.out.println(map1.get("a1"));
        System.out.println(map1.get(null));
        System.out.println("--------Lambda-----------");
        map1.forEach((k,v) -> System.out.println(k + "@" + v));
        System.out.println("--------匿名内部类-----------");
        map1.forEach(new BiConsumer<String, String>() {
            @Override
            public void accept(String k, String v) {
                System.out.println(k + "@" + v);
            }
        });
        System.out.println("----------keyset循环----------");
        Set<String> set = map1.keySet();
        for (String item: set) {
            System.out.println(item + "@" + map1.get(item));
        }

        System.out.println("----------EntrySet---------------------");
        Set<Map.Entry<String, String>> seten = map1.entrySet();
        for (Map.Entry<String, String> entry: seten) {
            System.out.println(entry.getKey() + "@" + entry.getValue());
        }

    }
}
